package com.hjf.booking.security.utils;

import java.util.Random;

/**
 * @author hjf
 * @date 2021-03-26 10:02
 */
public class StringRandomUtil {

    public static String generateString(int length){
        String baseStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZ-.0123456789";
        StringBuilder builder = new StringBuilder();
        Random random = new Random();
        for(int i=0;i<length;i++){
            int number = random.nextInt(38);
            builder.append(baseStr.charAt(number));
        }
        return builder.toString();
    }

    public static void main(String[] args) {
        String randomStr = generateString(30);
        System.out.println(randomStr);
    }

}
